|
|
|
|
|
|
|
Adding the Print Report Dialog Box Code |
|
|
|
|
|
|
|
|
After you have constructed the form, you need to add some code behind the form. First, declare two form-level variables in the declarations section. You'll use these variables to set the properties of the Crystal Reports Pro Control: |
|
|
|
|
|
|
|
|
Option Explicit
Dim cFileName As String
Dim cReportName As String |
|
|
|
|
|
|
|
|
The LoadFileTypes procedure loads the various report file types recognized by Crystal Reports Pro into a drop-down combo box. Add this procedure to your project: |
|
|
|
|
|
|
|
|
Private Sub LoadFileTypes ()
'
' load type selections
cboFileTypes.Clear
cboFileTypes.AddItem "Record"
cboFileTypes.AddItem "Tab Separated"
cboFileTypes.AddItem "Text"
cboFileTypes.AddItem "DIF"
cboFileTypes.AddItem "CSV"
cboFileTypes.AddItem "*RESERVED*"
cboFileTypes.AddItem "Tab Separated Text"
End Sub |
|
|
|
|
|
|
|
|
The code in the Form_Activate event initializes the form caption and the Crystal Reports Pro window caption. It also checks to see that a report name and database name have been passed to the form. This is where you load the combo box, too. |
|
|
|
|
|
|
|
|
Private Sub Form_Activate ()
'
' fix up form caption
If Len(Trim(Me.txtWindowTitle)) = 0 Then
Me.txtWindowTitle = "Print Report"
End If
Me.Caption = Me.txtWindowTitle
'
' check for passed database name
If Len(Trim(Me.txtReportDBName)) = 0 Then
MsgBox "Missing Database Name!"
Unload Me
End If
'
' check for passed report name
If Len(Trim(Me.txtReportName)) = 0 Then
MsgBox "Missing Report Name!"
Unload Me
End If
'
' set default copies
txtCopies = 1
'
LoadFileTypes ' fill drop down list box
End Sub |
|
|
|
|
|